package com.xyl.springboot.cfg;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.config.TopicBuilder;
import org.springframework.kafka.core.KafkaAdmin;

/**
 * 主题配置
 */
@Configuration
public class TopicConfig {

    /*
     * 使用Spring Boot时KafkaAdmin bean会自动注册，因此只需要NewTopic and/or NewTopics @Beans.
     */
    @Bean
    public KafkaAdmin.NewTopics topics() {
        return new KafkaAdmin.NewTopics(
                TopicBuilder.name(Constant.DB)
                        .partitions(1)
                        .replicas(1)
                        .build(),
                TopicBuilder.name(Constant.NB)
                        .partitions(1)
                        .replicas(1)
                        .build());
    }

}